package com.qzsoft.zhjd.exp.modules.platformlaboratorydatas.controller;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.exp.modules.platformlaboratorydatas.entity.PlatformLaboratoryDataEntity;
import com.qzsoft.zhjd.exp.modules.platformlaboratorydatas.service.PlatformLaboratoryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Title: save
 * @Description: 沥青实验数据
 * @return Result 沥青实验数据
 */
@RestController
@RequestMapping("/api/platformlaboratory")
public class PlatformLaboratoryDataController {
    @Autowired
    private PlatformLaboratoryDataService laboratoryDataService;


    /**
     * @Title: save
     * @Description: 沥青实验数据
     * @param entity 条件
     * @return Result 沥青实验数据
     */
    @PostMapping("save")
    public Result<String> save(@RequestBody PlatformLaboratoryDataEntity entity) {
        laboratoryDataService.saveAsphalt(entity);
        return ResultUtils.ok();
    }

    /**
     * @Title: save
     * @Description: 马歇尔实验
     * @param entity 条件
     * @return Result 马歇尔实验
     */
    @PostMapping("savemarshall")
    public Result<String> savemarshall(@RequestBody PlatformLaboratoryDataEntity entity) {
        laboratoryDataService.saveMarshall(entity);
        return ResultUtils.ok();
    }

    /**
     * @Title: save
     * @Description: 沥青实验数据
     * @param entity 条件
     * @return Result 沥青实验数据
     */
    @PostMapping("saveBatch")
    public Result<String> saveBatch(@RequestParam List<PlatformLaboratoryDataEntity> entity) {
        if(!CollectionUtils.isEmpty(entity)){
            for(PlatformLaboratoryDataEntity en:entity){
                laboratoryDataService.saveAsphalt(en);
            }
        }
        return ResultUtils.ok();
    }
}
